/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Date;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

/**
 *
 * @author A0077454
 */
@Entity
public class Transaction implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long transactionId;
    private String transactionNum;
    //private String accountType;
    private boolean debit;
    @ManyToOne(cascade = {CascadeType.PERSIST})
    private Customer customer;
    @ManyToOne(cascade = {CascadeType.PERSIST})
    private Supplier supplier;
    @ManyToOne(cascade = {CascadeType.PERSIST})
    private Invoice invoice;
    @ManyToOne(cascade = {CascadeType.PERSIST})
    private PaymentVoucher voucher;
    private String paymentType;
    
    @ManyToOne(cascade = {CascadeType.PERSIST})
    private Bank bank;
    @ManyToOne(cascade = {CascadeType.PERSIST})
    private BankAccount bankAccount;
    //private String creditGroup; // Cash, Bank //
    private String remark;
    
    private String chequeNo;
    private String TTNo;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private Currency currency;
    private Double conversionRate;
    private Double amountPaid;
    private Double totalPaid;
    private Date transactionTime;    
    private Date createdDate;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;

    public Transaction(){}
    
    public void create(Double conversionRate,  String transactionNum, boolean debit, String paymentType, String remark, String chequeNo, String TTNo, Double totalPaid, Double amountPaid, Date transactionTime, Date createdDate) {
        this.conversionRate = conversionRate;
        this.transactionNum = transactionNum;
        this.debit = debit;
        this.paymentType = paymentType;
        this.remark = remark;
        this.chequeNo = chequeNo;
        this.TTNo = TTNo;
        this.amountPaid = amountPaid;
        this.totalPaid = totalPaid;
        this.transactionTime = transactionTime;
        this.createdDate = createdDate;
    }

    public Double getConversionRate() {
        return conversionRate;
    }

    public void setConversionRate(Double conversionRate) {
        this.conversionRate = conversionRate;
    }

    public Currency getCurrency() {
        return currency;
    }

    public void setCurrency(Currency currency) {
        this.currency = currency;
    }

    public Double getTotalPaid() {
        return totalPaid;
    }

    public void setTotalPaid(Double totalPaid) {
        this.totalPaid = totalPaid;
    }

    public String getTransactionNum() {
        return transactionNum;
    }

    public void setTransactionNum(String transactionNum) {
        this.transactionNum = transactionNum;
    }

    
      
    public String getTTNo() {
        return TTNo;
    }

    public void setTTNo(String TTNo) {
        this.TTNo = TTNo;
    }

    public Double getAmountPaid() {
        return amountPaid;
    }

    public void setAmountPaid(Double amountPaid) {
        this.amountPaid = amountPaid;
    }

   

    public String getChequeNo() {
        return chequeNo;
    }

    public void setChequeNo(String chequeNo) {
        this.chequeNo = chequeNo;
    }

    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public boolean isDebit() {
        return debit;
    }

    public void setDebit(boolean debit) {
        this.debit = debit;
    }

    public Invoice getInvoice() {
        return invoice;
    }

    public void setInvoice(Invoice invoice) {
        this.invoice = invoice;
    }

    public String getPaymentType() {
        return paymentType;
    }

    public void setPaymentType(String paymentType) {
        this.paymentType = paymentType;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public Long getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(Long transactionId) {
        this.transactionId = transactionId;
    }

    public Date getTransactionTime() {
        return transactionTime;
    }

    public void setTransactionTime(Date transactionTime) {
        this.transactionTime = transactionTime;
    }

    public PaymentVoucher getVoucher() {
        return voucher;
    }

    public void setVoucher(PaymentVoucher voucher) {
        this.voucher = voucher;
    }

    public Bank getBank() {
        return bank;
    }

    public void setBank(Bank bank) {
        this.bank = bank;
    }

    public BankAccount getBankAccount() {
        return bankAccount;
    }

    public void setBankAccount(BankAccount bankAccount) {
        this.bankAccount = bankAccount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (transactionId != null ? transactionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transaction)) {
            return false;
        }
        Transaction other = (Transaction) object;
        if ((this.transactionId == null && other.transactionId != null) || (this.transactionId != null && !this.transactionId.equals(other.transactionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Transaction[ id=" + transactionId + " ]";
    }
    
    
    
    
     
    
}
